// 统一管理首页模块接口
import request from "@/utils/request";
import {
  HospitalInfo,
  HospitalLevelAndRegionResponseData,
  HospitalResponseData,
} from "./type";

// 通过枚举去管理首页模块的接口
enum API {
  // 获取已有的医院数据接口
  HOSPITAL_URL = "/hosp/hospital/",
  // 获取医院的等级与地区接口
  HOSPITAL_LEVEL_AND_REGION_URL = "/cmn/dict/findByDictCode/",
  // 根据医院的名字关键字获取数据
  HOSPITALINFO_URL = "/hosp/hospital/findByHosname/",
}

// 获取医院的数组
export const reqHospital = (
  page: number,
  limit: number,
  hostype = "",
  districtCode = ""
) => {
  return request.get<any, HospitalResponseData>(
    `${API.HOSPITAL_URL}${page}/${limit}?hostype=${hostype}&districtCode=${districtCode}`
  );
};

export const reqHospitalLevelAndRegion = (dictCode: string) => {
  return request.get<any, HospitalLevelAndRegionResponseData>(
    `${API.HOSPITAL_LEVEL_AND_REGION_URL}${dictCode}`
  );
};

export const reqHospitalInfo = (hosname: string) =>
  request.get<any, HospitalInfo>(`${API.HOSPITALINFO_URL}${hosname}`);
